package com.test.controller;

import com.test.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * @Author：徐志荣
 * @Date：2023/6/7 下午 7:43
 */
@Controller
public class StudentController2 {
    //方法2：使用 Setter方法
//    private final StudentService studentService;
    private  StudentService studentService;

    @Autowired
    public void setStudentService(StudentService studentService) {
        this.studentService = studentService;
    }

    public void sayHi(){
        //调用service方法
        studentService.sayHi();

        StudentController2 studentController = new StudentController2();
        studentController.setStudentService(null);

    }
}
